package com.ambimmort.shj.action.device;

import com.ambimmort.shj.service.device.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by zyt on 2015/7/30.
 */
@Controller("/action/device/enable.do")
public class Enable {
        @Autowired
        private DeviceService deviceService;
        @RequestMapping("/action/device/enable.do")
        @ResponseBody
        public String action_device(
                HttpServletRequest request, @RequestParam("id") String id, @RequestParam("device_status") String device_statu) {
            try {
                deviceService.enableDevice(id, device_statu);
                return "{\"result\":\"true\"}";
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                return "{\"result\":\"false\"}";
            }

        }
}
